package website.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import website.negocio.GestionResponsables;

/**
 * Servlet implementation class registrarOfertaServlet
 */
@WebServlet("/registrarOfertaServlet")
public class registrarResponsableServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public registrarResponsableServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String nomResponsable = request.getParameter("txtnombreResponsable").toUpperCase();
		String apePaterno = request.getParameter("txtApellidoPaterno").toUpperCase();
		String apeMaterno = request.getParameter("txtApellidoMaterno").toUpperCase();
		String sexo = request.getParameter("cboSexo").toUpperCase();
		String cboDoc = request.getParameter("cboDoc").toUpperCase();
		String numDoc=request.getParameter("txtNumDocumento");
		String email=request.getParameter("txtEmail").toUpperCase();
		String password=request.getParameter("txtPassword").toUpperCase();
				
			
		GestionResponsables negocio = new GestionResponsables();
		try {
			
			negocio.insertar(nomResponsable,apePaterno,apeMaterno,sexo,cboDoc,numDoc,email,password);
			String registro="Se realizo el registro al responsable "+ nomResponsable+" ...";
			
			request.setAttribute("registro",registro);
			RequestDispatcher rd = request.getRequestDispatcher("registrarReponsable.jsp");
			//response.sendRedirect(request.getContextPath()	+ "/ofertasAdministrador.jsp");
			rd.forward(request, response);
						
			
		} catch (website.excepcion.DAOExcepcion e) {
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
		}

		
		
		
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
